<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<style type="text/css">
		.text_box {
			width: 400px;
			height: 400px;
			margin: 0 auto;
			border: 1px solid #909090;
		}
		
		textarea {
			resize: none;
		}
	</style>

	<body>
		<div class="text_box">
			<textarea name="" rows="20" cols="60"  onKeyUp="value=value.replace(/\D/g,'')"></textarea><br />
			<span>				
			</span>
		</div>
		<script type="text/javascript">
			var texTarea = document.querySelector("textarea"),
				max = document.querySelector("max"),
				span = document.querySelector("span"),
				max = 50;
			texTarea.addEventListener("input", function() {
				length = texTarea.value.length;
				if(length >= max) {
					alert("你最多只能输入50个数字");
				}
				le=max-length;
				console.log(le);
				span.innerText = "剩余字数："+le+"";
			})
		</script>
	</body>

</html>